﻿/// Copyright © 2013 Microsoft Corporation. 
/// This project is released under the Microsoft Public License (MS-PL)
///
namespace DataMorph.Processing
{
    using System.Collections.Generic;
    using System.IO;

    public class TagDataFileParser : ITagDataFileParser
    {
        public IDictionary<string, IList<string>> Parse(Stream stream)
        {
            var result = new Dictionary<string, IList<string>>();
            using (var streamReader = new StreamReader(stream))
            {
                while (!streamReader.EndOfStream)
                {
                    var line = streamReader.ReadLine();
                    if (line != null)
                    {
                        var tagId = line.Substring(0, 36);
                        if (!result.ContainsKey(tagId))
                        {
                            result[tagId] = new List<string>();
                        }

                        result[tagId].Add(line);
                    }
                }
            }

            return result;
        }
    }
}